{
 "cells": [
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": "# 多维数组中使用数学和统计方法",
   "id": "c94e284f1cbfb093"
  },
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": [
    "## 1. 二维数组\n",
    "- axis = 0 : 沿着行方向操作（操作的的是列）\n",
    "- axis = 1 : 沿着列方向操作 （操作的是行）"
   ],
   "id": "6e85613659ee4929"
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-09-01T07:50:30.805881Z",
     "start_time": "2025-09-01T07:50:30.801651Z"
    }
   },
   "cell_type": "code",
   "source": [
    "import numpy as np\n",
    "arr1 = np.array([\n",
    "    [1,3,6],\n",
    "    [9,2,3],\n",
    "    [2,3,3]\n",
    "])\n",
    "print(f'原数组\\n：{arr1}')\n",
    "print(f'和\\n:{np.sum(arr1)}')\n",
    "print(f'每一列的和\\n:{np.sum(arr1,axis=0)}')\n",
    "print(f'每一行的和\\n:{np.sum(arr1,axis=1)}')\n",
    "print(f'每一列的平均值\\n:{np.mean(arr1,axis=0)}')\n",
    "print(f'每一行的平均值:\\n{np.mean(arr1,axis=1)}')\n"
   ],
   "id": "9f36b0bffa4aef87",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "原数组\n",
      "：[[1 3 6]\n",
      " [9 2 3]\n",
      " [2 3 3]]\n",
      "和\n",
      ":32\n",
      "每一列的和\n",
      ":[12  8 12]\n",
      "每一行的和\n",
      ":[10 14  8]\n",
      "每一列的平均值\n",
      ":[4.         2.66666667 4.        ]\n",
      "每一行的平均值:\n",
      "[3.33333333 4.66666667 2.66666667]\n"
     ]
    }
   ],
   "execution_count": 17
  },
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": "### 2. 二维数组中求众数",
   "id": "a4e175558534bd15"
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-09-01T08:00:22.909982Z",
     "start_time": "2025-09-01T08:00:22.905082Z"
    }
   },
   "cell_type": "code",
   "source": [
    "# 用Numpy找多维数组的众数需要先转换成一维数组才能找到，这样做太麻烦了\n",
    "print(arr1)\n",
    "print('=' * 30)\n",
    "# arr2 = arr1.flatten() # 将数组转成1维的\n",
    "# counts = np.bincount(arr2)\n",
    "# print(np.argmax(counts))\n",
    "# print('=' * 30)"
   ],
   "id": "414c926947319dac",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[1 3 6]\n",
      " [9 2 3]\n",
      " [2 3 3]]\n",
      "==============================\n"
     ]
    }
   ],
   "execution_count": 25
  },
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": "## 3.  将numpy转换成Pandas找众数",
   "id": "ad58606c2834c8b7"
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-09-01T08:04:15.502634Z",
     "start_time": "2025-09-01T08:04:15.498074Z"
    }
   },
   "cell_type": "code",
   "source": [
    "### 3.1 一维数组\n",
    "import pandas as pd\n",
    "a = np.array([1,2,2,3,4,5,2])\n",
    "s = pd.Series(a)\n",
    "print()"
   ],
   "id": "3214e5a1b9cbceab",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0    1\n",
      "1    2\n",
      "2    3\n",
      "3    4\n",
      "dtype: int64\n"
     ]
    }
   ],
   "execution_count": 29
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-09-01T08:06:07.987982Z",
     "start_time": "2025-09-01T08:06:07.974758Z"
    }
   },
   "cell_type": "code",
   "source": [
    "### 3.2 二维数组\n",
    "b = np.array([\n",
    "    [1,2,3],\n",
    "    [3,3,0],\n",
    "    [3,9,3]\n",
    "])\n",
    "\n",
    "df = pd.DataFrame(b)\n",
    "print(df.mode())"
   ],
   "id": "8bd8d44182740c6",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "     0  1    2\n",
      "0  3.0  2  3.0\n",
      "1  NaN  3  NaN\n",
      "2  NaN  9  NaN\n"
     ]
    }
   ],
   "execution_count": 31
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-09-01T08:18:54.629059Z",
     "start_time": "2025-09-01T08:18:54.622436Z"
    }
   },
   "cell_type": "code",
   "source": [
    "# 示例案例\n",
    "def describe_array(arr, axis=None):\n",
    "\n",
    "    \"\"\"生成数组的描述性统计\"\"\"\n",
    "    return {\n",
    "        'mean': np.mean(arr, axis=axis),\n",
    "        'std': np.std(arr, axis=axis),\n",
    "        'min': np.min(arr, axis=axis),\n",
    "        'max': np.max(arr, axis=axis),\n",
    "        'median': np.median(arr, axis=axis)\n",
    "    }\n",
    "\n",
    "arr1 = np.arange(1,22)\n",
    "\n",
    "arr1 = arr1.reshape(3,7)\n",
    "print(arr1)\n",
    "\n",
    "dict1 = describe_array(arr1,axis=0)\n",
    "print(f'数组每列的平均值\\n:{dict1[\"mean\"]}')\n",
    "print(f'数组每列的平均差\\n:{dict1[\"std\"]}')\n",
    "print(f'数组每列的最小值是\\n:{dict1[\"min\"]}')\n",
    "print(f'数组每列的最大值是\\n：{dict1[\"max\"]}')\n",
    "print(f'数组每列的中位数是\\n:{dict1[\"median\"]}')"
   ],
   "id": "bf0d8824608c335e",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[ 1  2  3  4  5  6  7]\n",
      " [ 8  9 10 11 12 13 14]\n",
      " [15 16 17 18 19 20 21]]\n",
      "数组每列的平均值\n",
      ":[ 8.  9. 10. 11. 12. 13. 14.]\n",
      "数组每列的平均差\n",
      ":[5.71547607 5.71547607 5.71547607 5.71547607 5.71547607 5.71547607\n",
      " 5.71547607]\n",
      "数组每列的最小值是\n",
      ":[1 2 3 4 5 6 7]\n",
      "数组每列的最大值是\n",
      "：[15 16 17 18 19 20 21]\n",
      "数组每列的中位数是\n",
      ":[ 8.  9. 10. 11. 12. 13. 14.]\n"
     ]
    }
   ],
   "execution_count": 44
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-09-01T08:51:35.465454Z",
     "start_time": "2025-09-01T08:51:35.461300Z"
    }
   },
   "cell_type": "code",
   "source": [
    "\n",
    "def remove_outliers_zscore(data, threshold=0.3):\n",
    "    \"\"\"使用Z-score去除异常值\"\"\"\n",
    "    z_scores = np.abs((data - np.mean(data)) / np.std(data))\n",
    "    return data[z_scores < threshold]\n",
    "\n",
    "arr3 = np.array([\n",
    "    17,19,22,32,12,23,25,29,900,-7\n",
    "])\n",
    "\n",
    "list1 = remove_outliers_zscore(arr3)\n",
    "print(\"原始数组:\", arr3)\n",
    "print(\"数组长度:\", len(arr3))\n",
    "print(list1)\n"
   ],
   "id": "d9aba352058b6285",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "原始数组: [ 17  19  22  32  12  23  25  29 900  -7]\n",
      "数组长度: 10\n",
      "[32 29]\n"
     ]
    }
   ],
   "execution_count": 67
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-09-01T09:15:48.811785Z",
     "start_time": "2025-09-01T09:15:48.803179Z"
    }
   },
   "cell_type": "code",
   "source": [
    "#1. 创建包含1000个随机数的数组，服从正态分布(μ=0, σ=1)\n",
    "from numpy import random\n",
    "arry = random.normal(0,1,1000)\n",
    "print(arry)\n",
    "# 2. 找出其中绝对值大于2的异常值及其索引\n",
    "def get_exception(data,ab=2):\n",
    "    mask = np.abs(data) > 2\n",
    "    return data[mask], np.where(mask)[0]\n",
    "\n",
    "dd,index = get_exception(arry)\n",
    "print(dd)\n",
    "print(index)\n",
    "\n",
    "\n",
    "\n"
   ],
   "id": "906bd4a156bb0325",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[-1.53098492e-02  5.79291500e-01  1.19580368e-01 -9.73068941e-01\n",
      "  1.19657150e+00 -1.58529573e-01 -2.73045395e-02 -9.33267959e-01\n",
      " -4.43282251e-01 -8.84802714e-01 -1.72946060e-01  1.71170848e+00\n",
      " -1.37190114e+00 -1.61356140e+00  1.47117033e+00 -2.09323677e-01\n",
      " -6.69072739e-01  1.03990469e+00 -6.05615540e-01  1.82600971e+00\n",
      "  6.77925871e-01 -4.87911408e-01  2.15730821e+00 -6.05714923e-01\n",
      "  7.42095372e-01  2.99292580e-01  1.30174129e+00  1.56151120e+00\n",
      "  3.20041491e-02 -7.53417870e-01  4.59972143e-01 -6.77715370e-01\n",
      "  2.01338725e+00  1.36535331e-01 -3.65321551e-01  1.84680306e-01\n",
      " -1.34712629e+00 -9.71614039e-01  1.20041391e+00 -6.56894279e-01\n",
      " -1.04691098e+00  5.36652753e-01  1.18570415e+00  7.18953311e-01\n",
      "  9.96047686e-01 -7.56795089e-01 -1.42181067e+00  1.50133365e+00\n",
      " -3.22679839e-01 -2.50833016e-01  1.32819414e+00  5.56230009e-01\n",
      "  4.55887772e-01  2.16500234e+00 -6.43518230e-01  9.27840128e-01\n",
      "  5.70131249e-02  2.68592279e-01  1.52846843e+00  5.07835756e-01\n",
      "  5.38296079e-01  1.07250734e+00 -3.64952730e-01 -8.39209667e-01\n",
      " -1.04480919e+00 -1.96635659e+00  2.05620713e+00 -1.10320837e+00\n",
      " -2.21253624e-01 -2.76813300e-01  3.07406698e-01  8.15737213e-01\n",
      "  8.60473488e-01 -5.83077439e-01 -1.67121714e-01  2.82579950e-01\n",
      " -2.48691126e-01  1.60734558e+00  4.90974952e-01  7.34877786e-01\n",
      "  6.62881269e-01  1.17347386e+00  1.81021559e-01 -1.29683195e+00\n",
      "  3.99687952e-01 -6.51356894e-01 -5.28616682e-01  5.86364019e-01\n",
      "  1.23828307e+00  2.12715767e-02  3.08833013e-01  1.70221494e+00\n",
      "  2.40753179e-01  2.60168311e+00  5.65509646e-01 -1.76076276e+00\n",
      "  7.53341621e-01  3.81158385e-01  1.28975275e+00  6.73181351e-01\n",
      " -1.38455984e-01 -1.22429824e+00 -2.09023257e-01 -8.50520454e-01\n",
      " -5.80523450e-01  5.88578404e-01  1.66990450e+00  3.94671530e-01\n",
      " -1.19588306e+00  4.44602668e-01  1.19663149e+00 -6.09782904e-01\n",
      " -1.34017167e-01  1.46881947e-02 -7.84898313e-01  6.48280434e-01\n",
      " -1.20948149e-01  4.19532444e-01 -8.87492178e-01 -4.37458300e-01\n",
      "  7.22381358e-01 -3.72833152e-01  1.72696385e+00 -3.99636186e-01\n",
      "  2.24684726e-01  9.32590832e-01 -1.41836573e+00 -1.76080881e+00\n",
      " -1.52565631e+00  1.26258410e+00 -5.51858146e-01  2.55819929e+00\n",
      " -5.64247599e-01  1.84551303e-01  1.54210995e+00  2.00609289e+00\n",
      "  2.06150358e+00  1.20836623e+00  1.02406253e+00  5.92526949e-01\n",
      "  7.78361076e-01 -5.51185716e-01 -8.18198883e-01 -3.37445741e-03\n",
      " -1.70184623e-01 -4.53228049e-01  6.96387447e-01  9.55305209e-01\n",
      "  8.84068863e-02  1.47753008e+00 -1.14168911e+00 -1.93659459e-01\n",
      " -7.16822321e-01 -1.86653662e+00 -8.26806858e-02 -1.21747508e-01\n",
      "  1.51344974e+00  6.30811685e-01 -1.02418682e+00  1.85409257e+00\n",
      "  1.22103370e+00  5.82097703e-01 -2.26484099e-01 -9.59439237e-01\n",
      " -3.72206776e-01  1.08874862e+00  1.88458631e+00  1.54324353e+00\n",
      " -4.88849422e-01 -1.11961743e+00  1.40886247e-01 -1.76843937e+00\n",
      "  3.23167714e-01 -1.47602586e-01 -4.66036502e-01 -1.59470307e+00\n",
      "  5.13600107e-01 -5.32700840e-01 -1.16991684e+00 -2.87226221e+00\n",
      " -2.75149051e-02  1.77225160e+00  1.66125921e+00 -4.57096257e-01\n",
      " -6.02212060e-01  4.68774256e-01 -9.98385439e-01  3.01791900e-01\n",
      "  7.66080278e-01  1.22693322e+00 -1.00154076e-01 -2.03673750e-01\n",
      " -8.77982587e-01 -8.26880354e-01 -2.26478892e-01  3.67365507e-01\n",
      "  9.13584626e-01 -8.03178951e-01  1.49268857e+00 -2.71123601e-01\n",
      " -2.13672943e-02 -7.47211679e-01 -2.42424026e+00  8.84045396e-01\n",
      "  7.36843897e-01 -2.81327557e-01  6.69907172e-02  5.15939218e-01\n",
      " -1.56254586e+00 -5.29052677e-01  7.94264680e-01 -1.25428942e+00\n",
      "  2.93557932e-01 -1.35658180e+00  4.66429982e-01 -3.56414823e-02\n",
      " -1.61513182e+00  1.16473935e+00 -7.34591577e-01 -8.10252437e-01\n",
      "  2.00569197e-01  1.14863735e+00 -1.01582182e+00  6.16798498e-02\n",
      "  4.28816500e-01  6.93105607e-01  1.76441555e-01 -3.67027839e-01\n",
      " -8.27590221e-01  8.61438830e-02 -1.07213901e+00 -2.92135048e+00\n",
      "  4.36559804e-01  9.03934841e-01 -2.36293244e+00 -1.00973070e+00\n",
      "  6.19154261e-01  2.05749547e+00  2.07937077e-02 -7.28002941e-01\n",
      " -1.82896441e-01  1.37487642e+00 -6.45964179e-01 -7.99192007e-01\n",
      " -4.82743522e-01 -9.53328608e-01  1.22670316e-01  1.62467846e+00\n",
      "  3.23079273e-01 -2.52353502e-01 -2.91811269e-01 -1.56319081e+00\n",
      "  8.83109777e-01 -7.78371970e-02 -1.80479914e-01  3.19310757e+00\n",
      "  2.98752908e-01 -7.51791050e-01 -4.26357596e-01  1.14844571e+00\n",
      "  1.13270411e-01 -1.43827798e+00  9.19228935e-01 -6.68144086e-01\n",
      "  1.87329778e+00  1.08004807e+00 -4.47321896e-01  1.28101636e+00\n",
      "  6.78555105e-02  8.52773675e-01  4.84732817e-01 -8.46356655e-01\n",
      " -6.43549832e-01  1.02996082e+00 -3.34775332e-01 -4.03648463e-01\n",
      " -9.55122579e-01  4.23599066e-01  2.06252492e+00 -1.06753291e+00\n",
      "  2.42194567e-02  1.41222056e+00 -7.96413912e-02  4.52371796e-01\n",
      " -1.06239353e+00  4.28307097e-01 -1.87144265e-01  9.85729996e-01\n",
      "  1.18738605e+00  2.58956364e+00  5.79633173e-01  3.25796317e-01\n",
      "  1.94384302e-01 -3.53166293e-01  3.38483843e-01 -2.95401410e-01\n",
      "  1.68460976e-01  1.31759754e+00 -1.00654257e+00  1.13987856e+00\n",
      "  1.31711507e+00 -1.18068527e-01 -2.12185490e+00 -6.07821987e-01\n",
      "  1.29699455e+00 -2.28680623e-02 -9.99302232e-01 -5.04774921e-01\n",
      "  8.40620027e-01  5.46733568e-01 -2.38932099e-01 -3.66824412e-01\n",
      " -3.91758149e-01 -9.22410184e-01  1.61537569e+00 -3.22320469e-01\n",
      "  1.21715852e+00  1.52131605e+00  9.98310898e-01 -4.31620313e-01\n",
      "  4.03730090e-01 -2.41956064e-02 -9.03701861e-01  3.24359282e-01\n",
      " -1.17903979e+00  1.18767939e+00 -4.64617297e-01  2.01159656e-01\n",
      "  2.83287872e-01 -2.58904974e-01  5.86693801e-01 -4.74903657e-01\n",
      "  8.71297297e-01 -1.34597968e+00  1.26379580e-01  1.93892900e+00\n",
      " -1.00033132e+00 -6.77744971e-01  5.13907850e-01  1.79581782e-01\n",
      "  3.50630099e-01  4.89187130e-01  6.34721469e-01  1.10969984e+00\n",
      "  4.09818657e-01 -2.41257655e-01  6.72573701e-01  1.89988193e+00\n",
      " -1.32633746e-01 -9.74529305e-01  1.10708067e+00 -1.20381164e-01\n",
      " -2.17266955e+00  8.47421677e-01 -5.35328186e-01 -9.05332823e-02\n",
      "  3.31980331e-01  1.90499680e-01  7.09451817e-01 -4.35486371e-01\n",
      "  5.13105798e-01 -2.59546678e-01  7.38810481e-01  6.15367484e-01\n",
      " -9.35438702e-01  1.08598212e+00 -5.35963445e-01  8.08057798e-01\n",
      "  3.67287313e-01  1.83818368e+00 -2.23465982e-01 -3.49316796e-01\n",
      " -1.94196059e-02 -3.03179783e-01  7.99941902e-01 -1.61631061e+00\n",
      " -1.05368242e+00 -1.06780292e+00  9.50307592e-01  1.71061337e+00\n",
      " -1.04449219e-01 -1.68821723e-01  7.00521631e-02  1.16187830e+00\n",
      " -9.27353134e-01  2.38368983e-01  9.75197630e-01  5.01094170e-01\n",
      "  1.89581617e-01  1.00104609e+00 -2.70323229e+00  6.77875320e-01\n",
      " -6.54075683e-01 -1.83063290e+00  5.11202600e-01  1.37365855e+00\n",
      " -1.37448515e-01  9.52874547e-01  1.61227826e+00  1.31491445e+00\n",
      "  1.63996453e+00  7.42127491e-01  7.54336389e-02 -1.60196581e+00\n",
      " -2.46062488e-01 -8.43246595e-01  2.17094272e+00 -1.75885812e-01\n",
      "  1.23204807e-01  5.51485376e-01  4.36024464e-02  1.69505104e+00\n",
      " -6.22649362e-01  1.94607455e-01 -7.42470586e-01 -1.32002251e+00\n",
      " -6.11769091e-01 -3.70367970e-02 -4.29302225e-01 -6.92420980e-01\n",
      " -1.40631746e+00 -8.31055726e-02 -1.50472037e+00  7.60055964e-01\n",
      "  8.24397529e-02 -1.45755150e+00 -3.09209077e-01 -7.52156406e-01\n",
      "  3.19174510e-01  1.34045045e+00 -1.87517247e+00  1.15026079e-01\n",
      " -1.60132796e-01  6.71340076e-01  2.13196628e-01 -7.51969332e-01\n",
      " -3.19053936e-01 -7.96025857e-01  1.07600714e+00  2.13116487e-02\n",
      "  1.90119069e+00 -6.06608138e-02 -7.08406767e-01 -1.51371439e+00\n",
      " -1.80313968e+00 -1.58413594e+00  2.67126651e-01  5.08725023e-01\n",
      " -1.58119070e+00  8.95038314e-01 -4.83061052e-01  1.46793012e-01\n",
      "  1.61222063e+00  8.96839316e-01 -2.68530648e-01 -8.91192225e-01\n",
      " -2.15181540e+00 -7.19153319e-01 -2.11130239e-01 -9.87179527e-01\n",
      " -1.31256967e-01  7.68518830e-02 -2.24855982e-01 -6.50002581e-01\n",
      "  1.68654672e-01  4.41940650e-01 -1.09039908e+00  1.41093238e+00\n",
      " -9.85881323e-02  1.88496229e-02  7.08214423e-01  2.33216131e-01\n",
      "  9.53136634e-01  2.87124165e-01 -6.12437375e-01  3.61503525e-01\n",
      " -1.14372621e+00  1.08559706e-01 -3.32299906e-02 -2.08116857e-01\n",
      " -1.28537511e-01 -1.88184905e+00 -5.48724908e-01  9.28449011e-02\n",
      "  1.59856392e-01 -1.02767514e+00  1.26570784e+00 -8.66174848e-01\n",
      "  9.69457201e-01  4.27194362e-01 -6.46227310e-01  1.77531089e+00\n",
      " -1.19363683e+00  9.19154174e-01  1.00058232e+00 -6.70620209e-01\n",
      "  1.39246530e+00 -2.50046515e-01  2.88693629e-01  2.60321839e-01\n",
      " -1.34308741e-01  8.10808273e-01  7.93488721e-01 -1.74853197e+00\n",
      "  1.30434024e+00 -1.66249199e+00  1.03254620e+00  1.12670514e+00\n",
      " -1.09096643e+00 -4.10814288e-01 -1.10570467e+00 -2.14921030e-01\n",
      " -3.08034284e-01  7.79660532e-01  1.31030875e+00  1.39568381e+00\n",
      " -5.62168027e-01 -2.09221874e-01 -1.68343819e+00 -8.05870066e-01\n",
      "  9.64851633e-01  1.61558282e+00 -1.23434887e+00 -5.92464259e-01\n",
      " -2.64057570e-02  2.80161159e-01 -8.09603520e-01  4.24061044e-01\n",
      " -4.73839347e-01 -1.44522709e-02  5.46284248e-01  6.42226981e-03\n",
      " -4.36385891e-01 -1.09609804e-01 -8.83629592e-02 -3.70011030e-01\n",
      " -2.58796063e-01  1.59864717e+00  5.60919448e-01 -2.95480318e-01\n",
      "  6.96954405e-01 -3.33819490e-01  1.17312464e+00  3.69642192e-01\n",
      " -1.07302144e-01  4.47716926e-01 -1.57087615e+00 -1.12676747e+00\n",
      " -1.19392501e+00  1.42943095e-01  1.73251500e+00  2.23130015e+00\n",
      "  6.38051101e-01  5.00844475e-01 -1.80105773e+00 -5.42673800e-01\n",
      " -7.87783752e-01 -6.20847598e-01 -1.68143819e-01 -4.72090578e-01\n",
      " -1.97929981e+00  7.47910256e-01 -1.07274303e+00  2.39246864e-01\n",
      "  2.07408267e+00 -9.19384592e-01 -2.53028752e+00 -2.86004222e-01\n",
      "  1.10095963e+00  1.95834745e+00 -1.22954959e+00  4.96699223e-01\n",
      " -4.65310457e-01 -1.05948354e-01  2.64434335e+00 -1.50297033e+00\n",
      "  2.53739661e-01  4.67693172e-01  1.08578632e+00  9.79831535e-02\n",
      "  3.08050540e-01 -3.91648567e-01  2.69126941e-01 -3.43192275e-01\n",
      "  6.21571890e-01 -3.69610336e-01  3.77100394e-01 -2.92628137e-02\n",
      "  1.12605025e+00 -5.13937236e-02 -1.77303247e+00  1.26192150e+00\n",
      " -9.05732301e-01 -6.53766339e-01 -5.95661294e-01  1.37443809e+00\n",
      " -2.13567421e+00  3.13774853e+00  1.05605681e+00  2.23238914e-01\n",
      " -5.48940006e-02  2.85554075e-01  5.21122428e-01  6.45215586e-01\n",
      "  5.55604466e-01  8.95806813e-02 -1.97338420e-01 -1.51273284e-01\n",
      " -1.94908280e-01  1.13377010e+00  5.93556722e-01 -2.94038863e+00\n",
      "  6.55900777e-01  1.94736195e-01 -1.87087564e-02 -3.88518453e-01\n",
      "  1.12411272e+00  9.47526462e-01 -7.72877668e-01  4.07052287e-01\n",
      " -9.71656735e-01 -1.37961816e+00 -6.26717225e-01  8.62393472e-01\n",
      "  9.53125045e-01  5.13085420e-01  7.25095787e-01  5.16178287e-01\n",
      " -6.41481595e-01  4.31922545e-01  8.00409525e-01  7.54291330e-01\n",
      "  1.18891337e+00  7.08303847e-01  3.51448208e-01  1.07015024e+00\n",
      " -2.65212592e-02 -8.81874651e-01 -1.63066964e-01 -7.44902645e-01\n",
      " -6.75178275e-01 -1.44518671e-01 -7.92419921e-01 -3.07961530e-01\n",
      " -1.89361467e+00  2.13293707e-01  1.20547536e-03 -8.17088631e-01\n",
      "  6.59245668e-01  9.37570138e-01 -1.60755986e+00 -7.62724779e-01\n",
      " -7.69142350e-01 -9.39903101e-01  8.29474842e-01 -1.93826139e-01\n",
      " -2.64514841e-01 -2.00386236e+00  6.35418030e-01 -1.23925839e+00\n",
      "  5.99326303e-02  2.77376938e-01  1.36065860e+00 -1.30882040e+00\n",
      " -3.01951216e+00  1.83849545e-01  1.80051118e+00  1.23894635e+00\n",
      "  2.09659415e-01 -4.91636186e-01  8.07122597e-01 -9.73546200e-01\n",
      "  4.76357769e-01  5.05470159e-01  1.06020991e+00  2.75966004e+00\n",
      "  3.92415967e-01 -5.08963626e-01 -2.55743122e-02 -1.76907590e+00\n",
      " -6.94713131e-01 -4.09282438e-01 -5.24088398e-01  1.52354872e-01\n",
      " -8.22419932e-01  1.12103067e+00  2.07064918e-04 -9.30032114e-03\n",
      " -3.27894717e-01  1.55190684e-01  8.25098265e-01 -8.67130216e-01\n",
      " -6.58116489e-01 -3.03726029e-01 -1.34587092e+00 -8.19257860e-01\n",
      " -4.76220874e-01  8.74389181e-01  2.62561329e-01  1.93589911e-01\n",
      "  8.50897962e-01 -1.37371788e-01  3.90464850e-01 -1.03221753e-01\n",
      "  2.65362349e-01 -5.82758658e-01 -2.43881716e+00 -1.34279162e-01\n",
      "  1.42274814e+00  9.26215402e-01  9.65397485e-01  1.23613072e+00\n",
      "  8.86575910e-02  1.97315707e-01 -6.17651895e-01 -3.16072856e-01\n",
      "  6.15771150e-01  1.20388444e+00 -1.39446276e-01 -4.50189265e-01\n",
      "  5.27958857e-04  6.01206749e-01 -1.44385482e+00 -2.29618095e+00\n",
      " -5.50536849e-01 -1.22071243e+00 -5.08140198e-01 -1.47780319e-01\n",
      " -4.53248409e-01  1.45246753e+00  3.26744765e-01  3.00474360e-01\n",
      "  6.22207144e-01 -1.13883312e+00  1.03911179e+00 -7.57642865e-02\n",
      "  6.70480617e-01 -1.07185723e+00 -1.55375877e+00  8.17889658e-01\n",
      "  3.76409526e-01 -9.02051554e-01 -8.69663081e-01  1.12543478e+00\n",
      " -1.18941189e+00  1.64267295e+00 -9.00620735e-01  6.38391926e-01\n",
      " -3.28618476e-01  6.03187431e-01 -5.44114002e-01 -1.62792906e-01\n",
      "  4.09191754e-02 -1.00218746e+00  7.40824345e-01 -5.13213566e-01\n",
      " -2.28599915e-01 -9.94349375e-01 -2.56233366e+00 -1.91027763e-01\n",
      "  2.41261542e+00  7.84604288e-01 -1.92603797e-02 -2.62890829e-01\n",
      "  2.24658928e-02  5.47119115e-01 -1.18081282e+00  1.11432169e+00\n",
      "  7.15381315e-01  7.18185726e-01  4.38475739e-01  1.96166577e-02\n",
      "  6.72861236e-01  5.91814134e-01 -3.54040711e-01 -5.73601773e-01\n",
      "  1.01856295e-01  1.54902015e+00 -1.23910708e+00 -1.46752527e+00\n",
      "  1.64760841e-01  5.08877019e-02  1.73341664e-01  2.43953198e-01\n",
      " -2.23202255e-01  1.48986344e+00 -1.60090398e+00 -8.28497025e-01\n",
      " -1.03254760e-01 -1.64318881e+00 -1.75854404e-01  1.66147017e+00\n",
      "  2.08864883e-02  2.30700906e-01 -1.26016477e+00 -6.16361408e-01\n",
      " -3.75196380e-01 -3.17715097e-01  1.28164380e+00  5.57691061e-01\n",
      " -1.11145796e+00  2.46504778e-01  4.98221748e-01  1.14014904e+00\n",
      "  1.58054069e+00 -1.01509419e+00 -8.10857511e-01 -1.25757786e+00\n",
      " -2.34019859e-01  4.66358374e-01  9.87334517e-01 -7.59510236e-02\n",
      " -3.19847523e-01  1.51757992e-01 -8.35142902e-01  2.08953872e+00\n",
      " -1.60766103e+00  1.84740579e-01  2.02360622e+00  6.79984456e-03\n",
      " -1.90039035e-01 -3.57445423e-01 -1.80391682e-01  1.37284847e+00\n",
      " -2.21186191e+00  1.53343370e+00 -1.42395715e+00 -2.66652329e-01\n",
      " -4.29244420e-01  5.88553270e-01 -1.59812435e+00  4.62172666e-01\n",
      "  2.02430962e+00 -1.36317400e+00  1.89706168e-01 -6.61982178e-01\n",
      "  4.25887206e-01  1.91477774e-02 -6.41486909e-01  4.87872285e-01\n",
      "  1.80434811e+00 -1.90903792e-01  7.19757942e-01 -1.29327296e+00\n",
      " -9.56436377e-01  4.72406278e-01  1.48411603e+00  3.55613349e-01\n",
      " -3.13058031e-01 -7.08594577e-04 -1.25040773e+00  6.04515326e-01\n",
      "  8.82333062e-01 -4.52090333e-01 -4.70042148e-01  2.65878230e-01\n",
      " -4.36719736e-01 -6.61326146e-02  2.09972179e+00 -2.47025701e-01\n",
      " -3.58340152e-01 -6.47541806e-01  7.44191971e-01 -1.81224173e-01\n",
      " -6.49373038e-01  1.32130403e+00  1.41960300e+00 -6.00423566e-01\n",
      " -1.86653995e+00  1.00751369e+00 -6.84629826e-01  7.90625599e-01\n",
      " -1.97010382e+00  8.92597338e-01 -1.21117193e+00  7.30764119e-01\n",
      "  1.42730678e-02 -9.53939419e-01 -4.07036313e-01  6.86318457e-01\n",
      "  1.05894453e-01  5.84412980e-01  1.97644058e+00 -1.56424161e+00\n",
      "  1.61721257e+00  1.04355938e-01 -8.98784048e-01 -1.33031363e+00\n",
      " -1.89120391e-01  9.21650112e-01 -1.27549120e-01  1.51115493e+00\n",
      " -1.45117569e+00 -1.20889478e-02 -1.25239344e+00  3.63631883e-01\n",
      "  8.86887390e-01 -4.20761794e-01 -2.60421386e+00  1.98948147e-01\n",
      "  4.36738552e-01  4.04294755e-01  1.23578219e+00 -1.07105368e+00\n",
      "  6.80216105e-01  1.19250751e+00 -1.77858758e+00  3.19651826e-01\n",
      " -5.04179831e-01 -8.15226731e-02  3.47676484e-01 -4.87228564e-01\n",
      " -6.75708079e-01  3.41524175e-02 -1.08724594e+00 -1.08582513e+00\n",
      "  6.79373283e-01 -1.14879404e+00  6.66312501e-01  4.62591293e-01\n",
      " -1.72580673e+00 -6.77564652e-01  1.19410940e+00 -9.81165531e-01\n",
      " -4.64404262e-01  4.62060893e-01  7.83390509e-01 -2.51538886e-01\n",
      " -5.97510195e-01  1.42236986e+00  1.73889966e+00  9.78858051e-01\n",
      "  8.53181426e-02 -8.08265722e-01 -8.30444407e-01  5.22514105e-01\n",
      "  4.18398221e-01  1.40159859e+00  6.50450093e-01 -1.50308030e+00\n",
      "  1.05194762e+00 -9.98060627e-01 -3.83971272e-01  2.50200206e-01\n",
      "  1.99566749e+00  3.10991856e+00  6.06723059e-01 -1.83196619e-01\n",
      "  5.34505648e-01  8.87655426e-01 -3.20667626e-01  1.79521136e+00\n",
      "  2.30070759e-01  4.97743089e-01  6.65924252e-01  4.21586611e-01\n",
      "  8.38940500e-01 -6.17253187e-01 -5.58301754e-01 -1.10015423e+00\n",
      "  4.39501231e-01  7.78936504e-01  4.57772866e-01  1.67449243e+00\n",
      " -5.59601883e-03  6.68741656e-01 -1.09170088e+00 -3.87099702e-01\n",
      "  6.95537758e-01  8.49102111e-01 -2.93966948e-01 -7.15992519e-02\n",
      " -1.51787375e+00 -3.57029201e-01  8.90383164e-01  5.75205016e-01\n",
      "  5.00665721e-01  4.97736872e-02  7.06315863e-03 -6.60321139e-01\n",
      "  6.98828420e-01  4.20972944e-01  4.92018848e-01 -5.26034843e-01\n",
      " -2.15334292e+00  1.09715271e+00 -4.78837456e-01 -8.62775764e-01\n",
      "  6.93478912e-01 -3.92012640e-01  1.05993638e+00  6.17005950e-01\n",
      "  6.83569323e-01 -1.36595571e+00  1.21194399e+00  2.61250531e-01\n",
      " -3.69277139e-01  1.43388467e-01 -1.77623523e+00  4.08652811e-01]\n",
      "[ 2.15730821  2.01338725  2.16500234  2.05620713  2.60168311  2.55819929\n",
      "  2.00609289  2.06150358 -2.87226221 -2.42424026 -2.92135048 -2.36293244\n",
      "  2.05749547  3.19310757  2.06252492  2.58956364 -2.1218549  -2.17266955\n",
      " -2.70323229  2.17094272 -2.1518154   2.23130015  2.07408267 -2.53028752\n",
      "  2.64434335 -2.13567421  3.13774853 -2.94038863 -2.00386236 -3.01951216\n",
      "  2.75966004 -2.43881716 -2.29618095 -2.56233366  2.41261542  2.08953872\n",
      "  2.02360622 -2.21186191  2.02430962  2.09972179 -2.60421386  3.10991856\n",
      " -2.15334292]\n",
      "[ 22  32  53  66  93 131 135 136 179 202 231 234 237 255 278 289 302 352\n",
      " 390 406 456 551 564 566 574 596 597 611 657 664 675 706 723 758 760 815\n",
      " 818 824 832 858 898 945 984]\n"
     ]
    }
   ],
   "execution_count": 100
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-09-01T09:06:50.921566Z",
     "start_time": "2025-09-01T09:06:50.918368Z"
    }
   },
   "cell_type": "code",
   "source": [
    "data = np.array([-1,2,-3,4,5,6])\n",
    "print(np.abs(data))"
   ],
   "id": "a3b30e84405fb0d9",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1 2 3 4 5 6]\n"
     ]
    }
   ],
   "execution_count": 73
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
